package com.compass.doctor.ui.patient.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.callback.OnCustomButtonClick
import com.compass.doctor.databinding.LayoutHospitalizedRecordItemBinding
import com.compass.doctor.databinding.LayoutInspectionRecordItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.ext.gone
import com.compass.framework.ext.onClick
import com.compass.framework.ext.visible
import com.compass.framework.manager.DictionariesManager
import com.compass.framework.model.InspectionRecord
import com.compass.framework.utils.DateUtils

/**
 * Description： 患者检查记录
 * Date:2024/2/1 14:40
 */
class PatientExamineAdapter :
    BaseRecyclerViewAdapter<InspectionRecord, LayoutInspectionRecordItemBinding>() {

    private lateinit var onCustomButtonClick: OnCustomButtonClick
    fun setBottomCallBack(onChatBottomClick: OnCustomButtonClick) {
        this.onCustomButtonClick = onChatBottomClick
    }


    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutInspectionRecordItemBinding>,
        item: InspectionRecord?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvInspectionName.text = item.inspectionName
            tvOrderNumber.text = item.id
            tvStatus.text =
                DictionariesManager.getOrderInspectionSourceString(item.status.toString())
            tvSeeDoctorTime.text = DateUtils.conversionTime(item.createTime, DateUtils.FORMAT_TWO)
            icDiagnosis.text = if (item.type == 1) "验" else "查"
            if (item.status == 0) {
                tvCancel.visible()
            } else {
                tvCancel.gone()
            }
            tvCancel.onClick {

                onCustomButtonClick.onButtonCallBack(position,"cancel")
            }
        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutInspectionRecordItemBinding {
        return LayoutInspectionRecordItemBinding.inflate(layoutInflater, parent, false)
    }
}